package com.ruoyi.eam.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.eam.doman.EamLocation;
import com.ruoyi.eam.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.eam.doman.EamManageH;
import com.ruoyi.eam.service.IEamManageHService;

import javax.annotation.Resource;

/**
 * 资产记录2Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-06-24
 */
@Service
public class EamManageHServiceImpl implements IEamManageHService 
{
    @Resource
    private EamManageHMapper eamManageHMapper;

    @Resource
    private EamManageDMapper eamManageDMapper;

    @Resource
    private EamAssetMapper eamAssetMapper;

    @Resource
    private UserMapper userMapper;

    @Resource
    private DeptMapper deptMapper;

    @Resource
    private EamLocationMapper locationMapper;

    @Resource
    private EamTypeMapper eamTypeMapper;

    /**
     * 查询资产记录2
     * 
     * @param manageId 资产记录2主键
     * @return 资产记录2
     */
    @Override
    public EamManageH selectEamManageHByManageId(Long manageId)
    {
        return eamManageHMapper.selectEamManageHByManageId(manageId);
    }

    /**
     * 查询资产记录2列表
     * 
     * @param eamManageH 资产记录2
     * @return 资产记录2
     */
    @Override
    public List<EamManageH> selectEamManageHList(EamManageH eamManageH)
    {
        List<EamManageH>  list = eamManageHMapper.selectEamManageHList(eamManageH);

        if(list.size()>0) {
            for (EamManageH manageH : list) {
                manageH.setEamManageD(eamManageDMapper.selectEamManageDByManageId(manageH.getAssetCode()));
                manageH.setEamAsset(eamAssetMapper.selectEamAssetByAssetId(manageH.getEamManageD().getAssetId()));
                manageH.setUser(userMapper.selectUserByUserId(manageH.getUsePerson()));
                manageH.setDept(deptMapper.selectDeptByDeptId(manageH.getUser().getDeptId()));
                manageH.setEamType(eamTypeMapper.selectEamTypeByTypeId(manageH.getEamAsset().getTypeId()));
                manageH.setEamLocation(locationMapper.selectEamLocationByLocationId(manageH.getEamManageD().getLocationId()));
            }
        }
        System.out.println(list.size());
        return list;
    }

    /**
     * 新增资产记录2
     * 
     * @param eamManageH 资产记录2
     * @return 结果
     */
    @Override
    public int insertEamManageH(EamManageH eamManageH)
    {
        eamManageH.setCreateTime(DateUtils.getNowDate());
        return eamManageHMapper.insertEamManageH(eamManageH);
    }

    /**
     * 修改资产记录2
     * 
     * @param eamManageH 资产记录2
     * @return 结果
     */
    @Override
    public int updateEamManageH(EamManageH eamManageH)
    {
        return eamManageHMapper.updateEamManageH(eamManageH);
    }

    /**
     * 批量删除资产记录2
     * 
     * @param manageIds 需要删除的资产记录2主键
     * @return 结果
     */
    @Override
    public int deleteEamManageHByManageIds(Long[] manageIds)
    {
        return eamManageHMapper.deleteEamManageHByManageIds(manageIds);
    }

    /**
     * 删除资产记录2信息
     * 
     * @param manageId 资产记录2主键
     * @return 结果
     */
    @Override
    public int deleteEamManageHByManageId(Long manageId)
    {
        return eamManageHMapper.deleteEamManageHByManageId(manageId);
    }

    @Override
    public int updateDelEamH(String[] manageIds) {
        return eamManageHMapper.updateDelEamH(manageIds);
    }
}
